from sort_A import simply_sort

n, k = map(int, input().split())
commands = list(map(int, input().split()))
before = sum(commands)
simply_sort(commands)

for i in range(k):
    commands[i] = int(str(commands[i]).replace("-", ""))

print(sum(commands))
